module teapo.storage.attached.indexedDB { export class StorageAccess implements attached.StorageAccess { constructor(private _db: IDBDatabase) { byFullPath: PropertiesByFullPath,
callback: (error: Error) => void): void { var transaction = this._db.transaction(['files', 'metadata'], 'readwrite');
transaction.onerror = (errorEvent) => callback(wrapErrorEvent(errorEvent, 'update: transaction'));
var filesStore = transaction.objectStore('files'); var outstandingRequests = 1;
function oneError(errorEvent: ErrorEvent, moreDescription) { if (!outstandingRequests) return;
callback(wrapErrorEvent(errorEvent, moreDescription));
function oneCompleted() { if (!outstandingRequests) return;
for (var fullPath in byFullPath) if (byFullPath.hasOwnProperty(fullPath)) { var getFile = filesStore.get(fullPath);
getFile.onerror = (errorEvent) => callback(wrapErrorEvent(errorEvent, 'update: objectStore(files).get(' + file + ')')); getFile.onsuccess = (event) => { var fileData: FileData = getFile.result || { path: fullPath, properties: {} }; var properties = fileData.properties || (fileData.properties = {}); properties[property] = value;
var putFile = filesStore.put(fileData);
putFile.onerror = (errorEvent) => callback(wrapErrorEvent(errorEvent, 'update: objectStore(files).get(' + file + ')-put(' + property + ',' + value + ')')); putFile.onsuccess = (event) =>
(errorEvent) => callback(wrapErrorEvent(errorEvent, 'update: _updateEditedUTC')));
callback: (properties: { [property: string]: string; }) => void): void {